package com.billion.netty.listener;

import com.github.pagehelper.util.StringUtil;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class NettyListener implements ChannelFutureListener {

    private final String msg;

    private final String mark;

    public NettyListener(String msg, String mark){
        this.msg = msg;
        this.mark = mark;
    }

    @Override
    public void operationComplete(ChannelFuture future) throws Exception {
        StringBuilder sb = new StringBuilder("");
        if(!StringUtil.isEmpty(mark)){
            sb.append("【").append(mark).append("】");
        }
        if (future.isSuccess()) {
            log.info(sb.toString()+"回写成功" + msg);
        } else {
            log.info(sb.toString()+"回写失败" + msg);
        }
    }
}
